package com.gxuwz.medical.domain.user;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Set;

import com.gxuwz.medical.database.DbUtil;

/**
 * 用户信息实体类
 *
 */
public class User {
	/**
	 * 工号
	 */
	private String userid;
	/**
	 * 密码
	 */
	private String pwd;
	/**
	 * 姓名
	 */
	private String fullname;
	
	public User(){
		
	}
   
	
	private void load(String userid){
		Connection conn =null;
		PreparedStatement pstmt=null;
		ResultSet rs=null;
		try{
			conn=DbUtil.getConn();
			pstmt=conn.prepareStatement("select * from user where userid=?");
			int index=1;
			pstmt.setString(index, userid);
			rs=pstmt.executeQuery();
			if(rs!=null){
				while(rs.next()){
					this.userid = rs.getString("userid");
					this.fullname = rs.getString("fullname");
					this.pwd = rs.getString("pwd");
					break;
				}
			}
		}catch(SQLException e){
			e.printStackTrace();
		}
		
	}
	
	public User(String userid) {
		
		load(userid);
	}

	public String getUserid() {
		return userid;
	}

	public void setUserid(String userid) {
		this.userid = userid;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public String getFullname() {
		return fullname;
	}

	public void setFullname(String fullname) {
		this.fullname = fullname;
	}


	@Override
	public String toString() {
		return "User [userid=" + userid + ", pwd=" + pwd + ", fullname=" + fullname + "]";
	}
	
}
